#ifndef STOPWATCH_VIEW_H_INCLUDED
#define STOPWATCH_VIEW_H_INCLUDED

#include <aknview.h>
#include "StopwatchModelObserver.h"

class CStopWatchContainer;
class CStopwatchModel;
class CPeriodic;

class CStopWatchView : public CAknView, private MStopwatchModelObserver
{
public:
  // constructors and destructor
  CStopWatchView();
  static CStopWatchView* NewL();
  static CStopWatchView* NewLC();
  void ConstructL();
  virtual ~CStopWatchView();

  // from base class CAknView
  TUid Id() const;
  void HandleCommandL(TInt aCommand);
  TTimeIntervalMicroSeconds32 StopWatchUpdateInterval() const;

protected:
  // from base class CAknView
  void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage);
  void DoDeactivate();
  void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
  void HandleForegroundEventL(TBool);

  void StartUpdateStopWatch();
  void StopUpdateStopWatch();
  void StoreStateL();
  void RestoreStateL();

  void UpdateUiL();

  //from MStopwatchModelObserver
  void StopwatchStarted();
  void StopwatchStopped();
  void StopwatchNewSnapshotValue(const TSnapshot& aSnapshot);
  void StopwatchReset();

  void StopwatchResetL();

//  void ExportDataL();
//  void ExportDataL(RWriteStream& aOutput);

private:
  CStopWatchContainer* iStopWatchContainer;
  CStopwatchModel* iModel;

  CPeriodic* iPeriodicTimeUpdate;

  static TInt TimeUpdateCB(TAny* aThis);
  void TimeUpdateCallbackL();
};

#endif // STOPWATCH_VIEW_H_INCLUDED
